<?php

namespace App\Modules\Admin\Http\Controllers\Water;

use App\Modules\Admin\Http\Controllers\BaseController;
use App\Modules\Admin\Http\Requests\Water\WaterDeviceRequest;
use App\Modules\Admin\Services\Water\WaterDeviceService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class WaterDeviceControllers extends BaseController
{
    public function __construct(WaterDeviceService $service)
    {
        $this->service = $service;
    }

    public function create(WaterDeviceRequest $request): JsonResponse
    {
        return $this->createService($request);
    }

    public function update(WaterDeviceRequest $request): JsonResponse
    {
        return $this->updateService($request);
    }

    public function details(Request $request): JsonResponse
    {
        $result = $this->service->detail($request);

        return $this->successJson($result, $this->service->getError());
    }
    public function show(Request $request): JsonResponse
    {
        $result = $this->service->show($request);
        if ($result){
            return $this->successJson($result, $this->service->getError());
        }else{
            return $this->errorJson($this->service->getError());
        }
    }
    public function updatedbjd(Request $request): JsonResponse
    {
        $result = $this->service->updatedbjd($request->all());
        if ($result){
            return $this->successJson($result, $this->service->getError());
        }else{
            return $this->errorJson($this->service->getError());
        }
    }
    public function getSelectlists(Request $request): JsonResponse
    {
        $result = $this->service->getSelectlists($request);
        return $this->successJson($result, $this->service->getError());
    }
    public function getJundaSelectlists(Request $request): JsonResponse
    {
        $result = $this->service->getJundaSelectlists($request);
        return $this->successJson($result, $this->service->getError());
    }
    public function getUserSelectlists(Request $request): JsonResponse
    {
        $result = $this->service->getUserSelectlists($request);
        return $this->successJson($result, $this->service->getError());
    }

    /**
     * 物业费 添加
     * @param Request $request
     * @return JsonResponse
     */
    public function getJundaFeeParamlists(Request $request): JsonResponse
    {
        $result = $this->service->getJundaFeeParamlists($request->all());
        if ($result){
            return $this->successJson($result, $this->service->getError());
        }else{
            return $this->errorJson($this->service->getError());
        }
    }
    /**
     * 物业费 添加
     * @param Request $request
     * @return JsonResponse
     */
    public function updatePropertyFee(Request $request): JsonResponse
    {
        $result = $this->service->updatePropertyFee($request->all());
        if ($result){
            return $this->successJson($result, $this->service->getError());
        }else{
            return $this->errorJson($this->service->getError());
        }
    }
    /**
     * 水费 添加
     * @param Request $request
     * @return JsonResponse
     */
    public function updateElectricity(Request $request): JsonResponse
    {
        $result = $this->service->updateElectricity($request);
        if ($result){
            return $this->successJson($result, $this->service->getError());
        }else{
            return $this->errorJson($this->service->getError());
        }
    }
    /**
     * 电费 添加
     * @param Request $request
     * @return JsonResponse
     */
    public function updateWaterRate(Request $request): JsonResponse
    {
        $result = $this->service->updateWaterRate($request);
        if ($result){
            return $this->successJson($result, $this->service->getError());
        }else{
            return $this->errorJson($this->service->getError());
        }
    }
}
